<%--
  Created by IntelliJ IDEA.
  User: LENOVO
  Date: 2021/2/3
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
    <%--引入外部js文件--%>
    <script src="js/jquery.min.js"></script>
    <script>
        //页面加载，绑定单击事件
        $(function () {
            $("#btn").click(function () {
                //发送Ajax请求
                $.ajax({
                    //编写json格式，设置属性
                    url: "user/ajax",
                    contentType: "application/json;charset=UTF-8",
                    data: '{"username":"f","password":"d","age":4}',
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        //data服务器端响应json数据
                        alert(data);
                        alert(data.username);
                    }
                });
            });
        });
    </script>
</head>
<body>
<a href="/user/string">string</a><br/>
<a href="/user/void">void</a><br/>
<a href="/user/forwardOrRedirect">forwardOrRedirect</a><br/>
<button id="btn">发送Ajax的请求</button>
<br/>
<a href="/user/modelandview">modelandview</a><br/>

</body>
</html>
